package com.hsw.t4;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Test {
    public static void main(String[] args) {
        String s="2020-12-12 12:23:12";
        //将字符串解析为时间对象
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime ldt = LocalDateTime.parse(s, dateTimeFormatter);
        System.out.println(ldt);
        LocalDateTime ldt1 = ldt.plusYears(1).plusMonths(2).plusDays(3).plusHours(4).plusMinutes(8).plusSeconds(45);
        System.out.println(ldt1);
        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH小时mm分钟ss秒");
        //将时间对象格式化为字符串
        String s2 = dateTimeFormatter1.format(ldt1);
        System.out.println(s2);
    }
}
